package xyz.yuanjilu.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import xyz.yuanjilu.dao.WeixinUserDao;
import xyz.yuanjilu.entity.WeixinMediaEntity;
import xyz.yuanjilu.entity.WeixinUserEntity;
import xyz.yuanjilu.service.WeixinUserService;
import xyz.yuanjilu.utils.StringUtils;



@Service("weixinUserService")
public class WeixinUserServiceImpl implements WeixinUserService {
	@Autowired
	private WeixinUserDao weixinUserDao;
	
	@Override
	public WeixinUserEntity queryObject(String id){
		return weixinUserDao.queryObject(id);
	}
	
	@Override
	public List<WeixinUserEntity> queryList(Map<String, Object> map){
		return weixinUserDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return weixinUserDao.queryTotal(map);
	}
	
	@Override
	public void save(WeixinUserEntity weixinUser){
		weixinUser.setCreateTime(new Date());
		weixinUserDao.save(weixinUser);
	}
	
	@Override
	public void update(WeixinUserEntity weixinUser){
		weixinUserDao.update(weixinUser);
	}
	
	@Override
	public void delete(String id){
		weixinUserDao.delete(id);
	}
	
	@Override
	public void deleteBatch(String[] ids){
		weixinUserDao.deleteBatch(ids);
	}

	@Override
	public void saveOrUpdate(WeixinUserEntity weixinUser) {
		if (weixinUser != null && StringUtils.isNotBlank(weixinUser.getId())) {
			if (this.queryObject(weixinUser.getId())==null) {
				this.save(weixinUser);
			}else {
				this.update(weixinUser);
			}
		}
		
	}
	
}
